import type {
  WechatLoginDto,
  WechatLoginResponseDto,
  UserSchoolListResponseDto,
  SwitchSchoolDto,
  SwitchSchoolResponseDto,
  CurrentSchoolInfoDto,
  ApplyTakerRequestDto,
  ApplyTakerResponseDto
} from '@/types/api';
import request from '@/utils/request';

// 用户端功能API
export const appApi = {
  // 微信小程序登录
  wechatLogin: async (data: WechatLoginDto): Promise<WechatLoginResponseDto> => {
    return await request.post('/app/auth/wechat/login', data);
  },

  // 用户退出登录
  userLogout: async (): Promise<void> => {
    return await request.post('/app/auth/logout');
  },

  // 获取用户学校列表
  getUserSchools: async (): Promise<UserSchoolListResponseDto> => {
    return await request.get('/app/users/schools');
  },

  // 切换学校
  switchSchool: async (data: SwitchSchoolDto): Promise<SwitchSchoolResponseDto> => {
    return await request.post('/app/users/switch-school', data);
  },

  // 获取当前学校信息
  getCurrentSchool: async (): Promise<CurrentSchoolInfoDto> => {
    return await request.get('/app/users/current-school');
  },

  // 申请成为接单员
  applyTaker: async (data: ApplyTakerRequestDto): Promise<ApplyTakerResponseDto> => {
    return await request.post('/app/users/apply-taker', data);
  }
};
